package triangle.dj.gui;

import java.awt.*; 
import java.applet.*; 
import java.awt.event.*;

import javax.swing.JApplet;
import javax.swing.JFrame;

import triangle.dj.DjGenerator;

public class DjFrame extends JFrame implements ActionListener 
{
	
	public static void main(String [] args)
	{
		DjFrame dj = new DjFrame();
		dj.init();
	}
	
	Button generateButton; 
	CheckboxGroup radioGroup; 
	Checkbox normal; 
	Checkbox liveweek; 

	public void init()  
	{ 
		setLayout(new FlowLayout()); 
		generateButton = new Button("Generate DJ for the week");  
		radioGroup = new CheckboxGroup(); 
		normal = new Checkbox("Normal Weeks", radioGroup, true); 
		liveweek = new Checkbox("Living Week", radioGroup,false); 
		add(generateButton); 
		add(normal); 
		add(liveweek); 
		this.setVisible(true);
		this.setSize(200, 300);
		generateButton.addActionListener(this); 
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
	}

	// Here we will show the results of our actions 
	public void paint(Graphics g) 
	{ 
		// If the radio1 box is selected then radio1.getState() will 
		// return true and this will execute 
		if (normal.getState()) {
			DjGenerator djg = new DjGenerator();
			djg.generateDj();
			System.out.println("Normal!!!");
		}
		// If it was not red we'll try if it is blue 
		else if (liveweek.getState()) {
			DjGenerator djg = new DjGenerator();
			djg.generateDj(true);
			System.out.println("Living week!!!");
		}
		// Since always one radiobutton must be selected it must be green 
		else {}
	}

	// When the button is clicked this method will get automatically called 
	// This is where you specify all actions.

	public void actionPerformed(ActionEvent evt)  
	{ 
		// Here we will ask what component called this method 
		if (evt.getSource() == generateButton)  
		{
			repaint();
		}
	} 
}